package jdbcmapper;

import lotus.domino.*;

/**
 * <p>Title: JDBC Mapper</p>
 *
 * <p>Description: Libraries to copy documents form Lotus Notes to jdbc
 * table</p>
 *
 * <p>Copyright: Copyright (c) 2005</p>
 *
 * <p>Company: The Salvation ARmy</p>
 *
 * @author Ansel Robateau
 * @version 1.1
 */
public class JavaAgent extends AgentBase {
    public JavaAgent() {
    }
    public void NotesMain(){
        try{
            Session session = getSession();
            AgentContext agentContext =
            session.getAgentContext();
            Database db = agentContext.getCurrentDatabase();

            DBMapper mapper = new DBMapper(session,db);
            mapper.setPriority(Mapping.INSTANT);
            mapper.processMapping(280000,15000);

        } catch(Exception e) {
          try{
            // Create an agent log
            Session session = getSession();
            Log log = session.createLog("AgentLog");
            log.openAgentLog();
            // Save the java error stack trace
            java.io.CharArrayWriter cw = new java.io.CharArrayWriter();
            java.io.PrintWriter pw = new java.io.PrintWriter(cw);
            e.printStackTrace(pw);
            // Log the error
            log.logError(Log.EV_UNKNOWN,cw.toString());
          }catch(lotus.domino.NotesException ne){
            ne.printStackTrace();
          }
        }
    }
}
